package servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 05-ServletContext对象
 * ④获取文件的mimeType
 *
 */
public class Demo08Servlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String fileName = "a.txt";
        String mimeType = getServletContext().getMimeType(fileName);
        System.out.println("mimeType = " + mimeType);

        String fileName2 = "girl.jpg";
        String mimeType2 = getServletContext().getMimeType(fileName2);
        System.out.println("mimeType2 = " + mimeType2);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
